home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume32 / perlref / part04 < prev    next >
Encoding:
Text File  |  1992-09-04  |  10.5 KB  |  410 lines

  1. Newsgroups: comp.sources.misc,comp.lang.perl
  2. From: jv@mh.nl (Johan Vromans)
  3. Subject:  v32i004:  perlref - Perl Reference Guide 4.035.1, Part04/04
  4. Message-ID: <1992Sep4.023951.12221@sparky.imd.sterling.com>
  5. X-Md4-Signature: 740d65e3802831b6eda1507cc78623f5
  6. Date: Fri, 4 Sep 1992 02:39:51 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: jv@mh.nl (Johan Vromans)
  10. Posting-number: Volume 32, Issue 4
  11. Archive-name: perlref/part04
  12. Supersedes: perlref: Volume 28, Issue 77-79
  13. Environment: Perl v4.035
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then feed it
  17. # into a shell via "sh file" or similar.  To overwrite existing files,
  18. # type "sh file -c".
  19. # Contents:  ChangeLog parr
  20. # Wrapped by kent@sparky on Wed Sep  2 21:35:22 1992
  21. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  22. echo If this archive is complete, you will see the following message:
  23. echo '          "shar: End of archive 4 (of 4)."'
  24. if test -f 'ChangeLog' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'ChangeLog'\"
  26. else
  27.   echo shar: Extracting \"'ChangeLog'\" \(4079 characters\)
  28.   sed "s/^X//" >'ChangeLog' <<'END_OF_FILE'
  29. XWed Sep  2 15:18:08 1992  Johan Vromans  (jv at largo)
  30. X
  31. X    * Makefile 2.7:
  32. X      Updated to 4.035.
  33. X      Add symbols for LATEX and DVIPS.
  34. X      Add entry for guide-test.ps.
  35. X      Add chapter 27.
  36. X      Do not run psneat since it produces incorrect code.
  37. X
  38. X    * ch22.tex 2.5:
  39. X      Refer to manual for scalar return values.
  40. X      Change 'Info is' to 'Returns'.
  41. X
  42. X    * ch00.tex 2.4:
  43. X      Decrease space before the table of contents.
  44. X      Add chapter 27.
  45. X
  46. X    * ch99.tex 2.3:
  47. X      Eliminate \newpage (moved to refmaster.tex).
  48. X
  49. X    * ch27.tex 1.2:
  50. X      New chapter 'Environment variables'.
  51. X
  52. X    * ch24.tex 2.3:
  53. X      $^L: New in 4.035.
  54. X
  55. X    * ch16.tex 2.3:
  56. X      s: Note bracketing quotes. Not a 4.035 feature.
  57. X
  58. X    * ch13.tex 2.3:
  59. X      stat: Indicate return of null list if the call fails.
  60. X
  61. X    * ch11.tex 2.3:
  62. X      eval: Fix typo run-time.
  63. X      rindex: Shorten description so substr fits on the same page.
  64. X
  65. X    * ch07.tex 2.3:
  66. X      Add gid to -rR/wW/xX. Separate -oO.
  67. X      -s: Make separate entry. Indicate that it returns the
  68. X      size. Not a 4.035 feature.
  69. X
  70. X    * ch04.tex 2.3:
  71. X      Make semicolon at end of BLOCK optional.
  72. X
  73. X    * ch02.tex 2.4:
  74. X      numeric: Add '1_2345' format (blech).
  75. X
  76. X    * ch01.tex 2.4:
  77. X      -0: Change 'See also -L'to 'See also '-l' (typo).
  78. X
  79. X    * refbase.sty 2.5:
  80. X      Updated to 4.035. Add \makeupspace.
  81. X
  82. X    * refmaster.tex 2.3:
  83. X      Add chapter 27. Change makeups.
  84. X
  85. X    * README 2.5:
  86. X      Updated to 4.035.
  87. X
  88. XFri May 22 09:14:22 1992  Johan Vromans  (jv at largo)
  89. X
  90. X    * refbase.sty 2.4:
  91. X      Michael Jaegermann, who donated the NFSS code, used his wife's
  92. X      account for mailing me, so his wife got the credits instead.
  93. X
  94. XThu Apr  9 16:25:29 1992  Johan Vromans  (jv at largo)
  95. X
  96. X    * ch22: 
  97. X      "...does include not OK."  You may want to change it to read
  98. X      "...does not include OK."
  99. X      Thanks to Ron Pool, ron_p@empire.cce.cornell.edu
  100. X
  101. XTue Mar  3 12:46:00 1992  Johan Vromans  (jv at largo)
  102. X
  103. X    * ch01: Correct '-L' to '-l'.
  104. X      Thanks to Chris Eich <chrise@hpsrcje.sr.hp.com>.
  105. X
  106. X    * ch10: Add v/V to TEMPLATE.
  107. X      Thanks to DaviD W. Sanderson (dws@cs.wisc.edu)
  108. X
  109. XWed Feb 19 15:02:26 1992  Johan Vromans  (jv at largo)
  110. X
  111. X     * Released to USEnet. Official version is 4.019.1.
  112. X
  113. X    * refbase.sty: add support for new font selection scheme.
  114. X      Get rid of overfull hboxes.
  115. X
  116. X    * refbase.sty, refmaster.tex, ch*.tex: update for 4.019.
  117. X      Add description for "sort { EXPR;...} @array" .
  118. X      Describe "eval { ... }" .
  119. X      Add "scalar(@array)" and "scalar(%array)" .
  120. X      Small corrections.
  121. X
  122. X    * Makefile: new kit assembly.
  123. X
  124. XTue Aug 27 18:41:42 1991  Johan Vromans  (jv at largo)
  125. X
  126. X    * ch22: add 'gethostbyaddr'
  127. X
  128. XFri Aug  2 09:44:47 1991  Johan Vromans  (jv at largo)
  129. X
  130. X    * parr: add code for duplex printing.
  131. X
  132. X    * README: describe duplex printing, version number.
  133. X
  134. XSat Jul 27 15:23:01 1991  Johan Vromans  (jv at pronto)
  135. X
  136. X    * parr: Adjusted '%%Pages:' to reflect actual number of sheets.
  137. X
  138. XFri Jul 26 23:10:00 1991  Johan Vromans  (jv at pronto)
  139. X
  140. X    * Add Layout document that describes in more detail how the
  141. X      Reference Guide should look like.
  142. X
  143. X    * Makefile/README: Incorporate Layout.
  144. X
  145. XFri Jul 26 09:15:58 1991  Johan Vromans  (jv at largo)
  146. X
  147. X    * Released to USEnet (patch). Official version is 4.010.2.1.
  148. X
  149. X    * ch04: typo: | -> || (two locations)
  150. X
  151. X    * parr: slightly increase $topmargin for US paper.
  152. X
  153. X    * ch06: typo: log or/and | & -> || &&
  154. X
  155. XThu Jul 25 11:11:24 1991  Johan Vromans  (jv at largo)
  156. X
  157. X    * Makefile/README: Clarify the use of guide-{odd,even?}.ps.
  158. X
  159. X    * parr: Suppress extraneous %%Page comments to obtain more
  160. X      conformant PostScript. Some PS viewers and printers (or
  161. X      print-spoolers) seem to choke in these extraneous comments.
  162. X
  163. X      Set $leftmargin to 0 for US-Letter format. According to most
  164. X      respondents this seems to be the correct value.
  165. X
  166. XTue Jul 23 18:32:54 1991  Johan Vromans  (jv at largo)
  167. X
  168. X    * Makefile: allow MASTER=test for testing.
  169. X
  170. X    * ch03: typo: $var -> $#var is last element of array.
  171. X
  172. X    * ch00: move front page info a bit down/right.
  173. X
  174. XMon Jul 22 22:05:57 1991  Johan Vromans  (jv at pronto)
  175. X
  176. X    * ch00: typo: deigned -> designed.
  177. X
  178. XSat Jul 20 00:31:47 1991  Johan Vromans  (jv at pronto)
  179. X
  180. X    * Released to USEnet. Official version is 4.010.1.8.
  181. X
  182. X    * This is a brand new version.
  183. X
  184. END_OF_FILE
  185.   if test 4079 -ne `wc -c <'ChangeLog'`; then
  186.     echo shar: \"'ChangeLog'\" unpacked with wrong size!
  187.   fi
  188.   # end of 'ChangeLog'
  189. fi
  190. if test -f 'parr' -a "${1}" != "-c" ; then 
  191.   echo shar: Will not clobber existing file \"'parr'\"
  192. else
  193.   echo shar: Extracting \"'parr'\" \(4291 characters\)
  194.   sed "s/^X//" >'parr' <<'END_OF_FILE'
  195. X#!/usr/bin/perl
  196. X
  197. X# @(#)@ parr 4.2.3
  198. X
  199. X# rearrange conforming PS code to print the pages in an arbitrary
  200. X# order.  The -o option takes a list of ranges, like this:
  201. X#    1-5    1-10,11-20    11-,1-10
  202. X# usage: parr [-a4] [-o list] [file]
  203. X#
  204. X# jgreely@cis.ohio-state.edu, 89/10/23
  205. X# modified by jv@mh.nl, 91/078/15
  206. X
  207. X$order='';
  208. X$signFlag='';
  209. X$signCount=0;
  210. X$DEBUG=0;
  211. X$TMPDIR='/usr/tmp';
  212. X
  213. Xwhile ($_ = $ARGV[0],/^-/) {
  214. X    shift;
  215. X    last if /^-\-$/;
  216. X    /^-o(rder)?$/ && ($order = shift,next);
  217. X    /^-a4$/ && ($a4flag++,next);
  218. X    die "usage: parr [-a4] [-order list] [file]\n";
  219. X}
  220. X
  221. X$file = "$TMPDIR/p$$.header";
  222. X@files = ($file);
  223. X$sheet=0;
  224. Xopen(FILE,">$file") || die "$file: $!\n";
  225. Xwhile (<>) {
  226. X    #
  227. X    # hack to use NeXT Preview: strip old '%%Pages:' lines
  228. X    #
  229. X    next if /^%%Pages:/;
  230. X    if (/^%%Page:/) {
  231. X        $sheet++;
  232. X        $pagemap{$sheet} = $1 if /%%Page:\s+(\S+)\s+\S+/;
  233. X        close(FILE);
  234. X        $file = "$TMPDIR/p$$.$sheet";
  235. X        push(@files,$file);
  236. X        open(FILE,">$file") || die "$file: $!\n";
  237. X    }
  238. X    if (/^%%Trailer/) {
  239. X        close(FILE);
  240. X        $file = "$TMPDIR/p$$.trailer";
  241. X        push(@files,$file);
  242. X        open(FILE,">$file") || die "$file: $!\n";
  243. X    }
  244. X    if (/^TeXDict begin @(a4|letter)/) {
  245. X        # Insert twoup before switching to TeXDict
  246. X        &twoup;
  247. X        $twoup++;
  248. X        &double_sided;
  249. X        print FILE "TeXDict begin @landscape\n";
  250. X        next;
  251. X    }
  252. X    print FILE $_;
  253. X}
  254. Xclose(FILE);
  255. Xdie "twoup insertion error\n" unless $twoup == 1;
  256. X
  257. X@order = ();
  258. Xif ($order) {
  259. X    foreach $range (split(/,/,$order)) {
  260. X        ($start,$sep,$end) = split(/(-)/,$range);
  261. X        $start = 1 unless $start;
  262. X        $end = $sheet unless $end;
  263. X        if ($sep) {
  264. X            push(@order,$start..$end);
  265. X        }else{
  266. X            push(@order,$start);
  267. X        }
  268. X    }
  269. X}elsif ($signFlag) {
  270. X    if (! $signCount) {
  271. X        $signCount = $sheet;
  272. X        $signCount += (4 - $sheet % 4) if ($sheet % 4);
  273. X    }else{
  274. X        $signCount *=4;
  275. X    }
  276. X    for($base=0;$base<$sheet;$base+=$signCount) {
  277. X        @tmp = ($signCount/2+$base);
  278. X        push(@tmp,$tmp[0]+1,$tmp[0]+2,$tmp[0]-1);
  279. X        while ($tmp[3] > $base) {
  280. X            push(@order,@tmp);
  281. X            @tmp = ($tmp[0]-2,$tmp[1]+2,$tmp[2]+2,$tmp[3]-2);
  282. X        }
  283. X    }
  284. X}else{
  285. X    @order = (1..$sheet);
  286. X}
  287. X
  288. X@tmp=@order;
  289. X@order=();
  290. Xforeach $page (@tmp) {
  291. X    push(@order,$page > $sheet ? "B" : $page);
  292. X}
  293. X
  294. Xopen(FILE,"$TMPDIR/p$$.header");
  295. X$_ = <FILE>;
  296. Xprint $_,"%%Pages: (atend)\n";
  297. Xprint while <FILE>;
  298. Xclose(FILE);
  299. X
  300. X$count = 0;
  301. Xforeach $page (@order) {
  302. X    $count++;
  303. X    $num = "?";
  304. X    $num = $pagemap{$page} if defined $pagemap{$page};
  305. X    $num .= "/" . $pagemap{$order[$count]} 
  306. X        if defined $pagemap{$order[$count]};
  307. X    print "%%Page: $num ", ($count+1)/2, "\n" if $count & 1;
  308. X    print "%%OldPage: $page\n";
  309. X    if ($page eq "B") {
  310. X        print "showpage\n";
  311. X    }else{
  312. X        open(FILE,"$TMPDIR/p$$.$page");
  313. X        while (<FILE>) {
  314. X            print unless /^%%Page:/;
  315. X        }
  316. X        close(FILE);
  317. X    }
  318. X}
  319. Xopen(FILE,"$TMPDIR/p$$.trailer");
  320. Xprint while <FILE>;
  321. Xclose(FILE);
  322. Xprint "%%Pages: ", int(($count+1)/2), " 0\n";
  323. X
  324. Xunlink @files unless $DEBUG;
  325. Xexit(0);
  326. X
  327. Xsub twoup {
  328. X$factor = 0.707106781187;
  329. X
  330. X# Measurements are in 1/100 inch approx.
  331. Xif ( $a4flag) {
  332. X    $topmargin = -57;
  333. X    $leftmargin = 28;
  334. X    $othermargin = 445;    # do not change -- relative to $leftmargin
  335. X}
  336. Xelse {
  337. X    $topmargin = -30;
  338. X    $leftmargin = 0;
  339. X    $othermargin = 445;    # do not change -- relative to $leftmargin
  340. X}
  341. X$vsize = -1 - $factor;
  342. Xprint FILE <<EOD;
  343. X/isoddpage true def
  344. X/orig-showpage /showpage load def
  345. X/showpage {
  346. X        isoddpage not { orig-showpage } if
  347. X        /isoddpage isoddpage not store 
  348. X    } def
  349. X/bop-hook {
  350. X    /vsize $vsize def
  351. X        isoddpage 
  352. X    { $factor $factor scale $topmargin $leftmargin translate }
  353. X        { 0 $othermargin translate}
  354. X    ifelse
  355. X    } def
  356. X/end-hook{ isoddpage not { orig-showpage } if } def
  357. XEOD
  358. X}
  359. X
  360. Xsub double_sided {
  361. X
  362. X    # From: Tim Huckvale <tjh@praxis.co.uk>
  363. X    #
  364. X    # You may be interested in the following problem, and fix, that we
  365. X    # found when attempting to print the reference card on our Hewlett
  366. X    # Packard Laser-Jet IIISi printer.
  367. X    # 
  368. X    # On this printer, refguide.ps prints double-sided with the
  369. X    # reverse side of each sheet upside down.  We fixed it with the
  370. X    # following patch, applied before printing.
  371. X
  372. X    # From: Johan Vromans <jv@mh.nl>
  373. X    #
  374. X    # Okay -- consider this an unsupported feature.
  375. X
  376. X    print FILE <<EOD;
  377. Xstatusdict /setduplexmode known { statusdict begin true setduplexmode end } if
  378. Xstatusdict /settumble known { statusdict begin true settumble end } if
  379. XEOD
  380. X}
  381. X
  382. X# Local Variables:
  383. X# mode:(perl)
  384. X# End:
  385. END_OF_FILE
  386.   if test 4291 -ne `wc -c <'parr'`; then
  387.     echo shar: \"'parr'\" unpacked with wrong size!
  388.   fi
  389.   # end of 'parr'
  390. fi
  391. echo shar: End of archive 4 \(of 4\).
  392. cp /dev/null ark4isdone
  393. MISSING=""
  394. for I in 1 2 3 4 ; do
  395.     if test ! -f ark${I}isdone ; then
  396.     MISSING="${MISSING} ${I}"
  397.     fi
  398. done
  399. if test "${MISSING}" = "" ; then
  400.     echo You have unpacked all 4 archives.
  401.     rm -f ark[1-9]isdone
  402. else
  403.     echo You still must unpack the following archives:
  404.     echo "        " ${MISSING}
  405. fi
  406. exit 0
  407. exit 0 # Just in case...
  408.